const http = require('http');

// 创建http服务
const server = http.createServer((req, res) => {

    console.log('------------req method--------------');
    console.log(req.method);
    console.log('------------req url--------------');
    console.log(req.url);
    console.log('------------req httpVersion--------------');
    console.log(req.httpVersion);
    console.log('------------req headers--------------');
    console.log(req.headers);

    // 设置响应头
    res.setHeader('Content-Type', 'text/plain; charset=utf-8');
    // 设置响应体
    res.end('hello,你好,123')
})

// 监听9000端口
server.listen(9000, () => {
    console.log('服务启动了');
})